package cn.edu.csust.coursecard.controller;

import cn.edu.csust.coursecard.annotation.RequiredAdmin;
import cn.edu.csust.coursecard.dao.entity.RecruitInfo;
import cn.edu.csust.coursecard.common.ReturnData;
import cn.edu.csust.coursecard.service.RecruitInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("recruitInfo")
public class RecruitInfoController {
    @Autowired
    RecruitInfoService recruitInfoService;

    @PostMapping("/add")
    @RequiredAdmin
    public ReturnData addRecruitInfo(RecruitInfo recruitInfo){
        return recruitInfoService.addRecruitInfo(recruitInfo);
    }

    @GetMapping("/delete")
    @RequiredAdmin
    public ReturnData deleteRecruitInfo(Integer id){
        return recruitInfoService.deleteRecruitInfo(id);
    }

    @GetMapping("/getAll")
    public ReturnData deleteAllRecruitInfo(){
        return recruitInfoService.getAllRecruitInfo();
    }

    @GetMapping("get")
    public ReturnData getRecruitInfo(Integer id){
        return recruitInfoService.getRecruitInfo(id);
    }

    @GetMapping("getByTitle")
    public ReturnData getRecruitInfo(String name){
        return recruitInfoService.getRecruitInfoByTitle(name);
    }


}
